<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <title>fly-platform-data-process</title>
</head>

<body>
  <div id="app"></div>
  <!-- built files will be auto injected -->
</body>

<script>
  var docEl = document.documentElement
  var dpr = window.devicePixelRatio || 1
  // 设置 1rem = 屏幕宽度的十分之一
  // 因此如果设计图宽 = 750px
  // 一个按钮的宽度为75px时，那么等于 75 / 750 = 1rem
  // 因此很简单，rem = 元素大小 / 设计图宽度
  function setRemUnit() {
    var rem = docEl.clientWidth / 10
    docEl.style.fontSize = rem + 'px'
  }
  setRemUnit()

  // 调整body的fontsize，不跟随html的fontsize，因为html的fontsize会动态变化
  function setBodyFontSize() {
    if (document.body) {
      document.body.style.fontSize = (12 * dpr) + 'px'
    }
    else {
      document.addEventListener('DOMContentLoaded', setBodyFontSize)
    }
  }
  setBodyFontSize();

  // reset rem unit on page resize
  window.addEventListener('resize', setRemUnit)
  window.addEventListener('pageshow', function (e) {
    if (e.persisted) {
      setRemUnit()
    }
  })

  // detect 0.5px supports
  //适配iOS，retain屏
  if (dpr >= 2) {
    var fakeBody = document.createElement('body')
    var testElement = document.createElement('div')
    testElement.style.border = '.5px solid transparent'
    fakeBody.appendChild(testElement)
    docEl.appendChild(fakeBody)
    if (testElement.offsetHeight === 1) {
      docEl.classList.add('hairlines')
    }
    docEl.removeChild(fakeBody)
  }

</script>

</html>